<?php

namespace Beerus\Modules\Designer\Actions;

use Doraemon\model\AdmDesignerArea;
use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;

class DelArea extends RowAction
{
    public $name = '删除';

    public function handle($id)
    {
        $area = AdmDesignerArea::get('*', ['id' => $id]);
        if ($area && !AdmDesignerArea::delete(['id' => $id])) {
            return $this->response()->error('删除失败');
        }
        return $this->response()->success('删除成功')->refresh();
    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }
        return $key;
    }

    public function dialog()
    {
        $this->confirm('确定删除？');
    }
}
